/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.component.jpanel;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.LayoutManager;
import java.awt.TexturePaint;

import javax.swing.JPanel;

import com.ruipengkj.commons.util.Util;
import com.ruipengkj.factory.ImageFactory;
/**
 * 说明：
 * 以图片做背景的面板
 */
public class RPJPanelOrderDispose extends JPanel {

	private static final long serialVersionUID = 1L;

	/**
	 * 背景图片
	 */
	private TexturePaint paint = Util.createTexturePaint(ImageFactory.loadImage(ImageFactory.JP_ORDER_DISPOSE_BG).getImage());
	private Image backgroundLeftImage = ImageFactory.loadImage(ImageFactory.JP_ORDER_DISPOSE_BG_LEFT).getImage();
	private Image backgroundRightImage = ImageFactory.loadImage(ImageFactory.JP_ORDER_DISPOSE_BG_RIGHT).getImage();
	
	
	public RPJPanelOrderDispose() {}
	public RPJPanelOrderDispose(LayoutManager layout) {
		super(layout);
	}

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
		Graphics2D g2d = (Graphics2D) g;
		g2d.drawImage(backgroundLeftImage, 0, -1, null);
		g2d.setPaint(paint);
		int x = backgroundLeftImage.getWidth(null);
		int y = 0;
		int width = getWidth() - x - backgroundRightImage.getWidth(null);
		int height = getHeight();
		g2d.fillRect(x, y, width, height);
		g2d.drawImage(backgroundRightImage, x + width, -1, null);
	}
}
